﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Autobiography.Helpers
{
    public static class DateTimeExtensions
    {
        public static DateTime FirstDayOfWeek(this DateTime dt)
        {
            return dt.FirstDayOfWeek(DayOfWeek.Sunday);
        }

        public static DateTime FirstDayOfWeek(this DateTime dt, DayOfWeek startDay)
        {
            DateTime temp = dt;
            while (temp.DayOfWeek != startDay)
            {
                temp = temp.AddDays(-1);
            }
            return temp;
        }
    }
}
